package com.ccl.myblog.utils;


import java.text.DecimalFormat;
import java.util.Random;

/**
 * 获取随机数
 * 
 * @author qianyi
 *
 */
public class RandomUtil {

	private static final Random RANDOM = new Random();

	private static final DecimalFormat FOURDF = new DecimalFormat("0000");

	private static final DecimalFormat SIXDF = new DecimalFormat("000000");

	private static final Integer MIN = 100000000;
	private static final Integer MAX = 999999999;

	public static String getFourBitRandom() {
		return FOURDF.format(RANDOM.nextInt(10000));
	}

	public static String getSixBitRandom() {
		return SIXDF.format(RANDOM.nextInt(1000000));
	}

	public static Integer getEightBitRandom() {
		return RANDOM.nextInt(MAX) % (MAX - MIN + 1) + MIN;
	}

	public static void main(String[] args) {
		System.out.println(getEightBitRandom());
	}
}
